package blue.mqtt4j.client;

import java.util.Collection;
import java.util.List;

/**
 * @author Jin Zheng
 * @since 1.0 2020-10-28
 */
public class MqttProducerException extends MqttClientException
{
	private static final long serialVersionUID = 1L;

	private List<ProducerResult> resultList;

	public MqttProducerException(Collection<ProducerResult> resultList)
	{
		super("MqttProducerException");
		if (resultList == null || resultList.isEmpty())
		{
			this.resultList = List.of();
		}
		else
		{
			this.resultList = List.copyOf(resultList);
		}
	}

	public List<ProducerResult> results()
	{
		return resultList;
	}

	@Override
	public String getMessage()
	{
		return resultList.toString();
	}

	@Override
	public String getLocalizedMessage()
	{
		return this.getMessage();
	}

	@Override
	public String toString()
	{
		return this.getMessage();
	}
}
